﻿using HC.View;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace EMRView.Extensions.Command.StandardCommand.Insert
{
    public partial class Frm_AddExpress : Form
    {
        private HCTextRectItem item;
        private HCEmrView emrView;
        public HCTextRectItem ExpressItem { get { return item; } }

        public Frm_AddExpress(HCEmrView view)
        {
            InitializeComponent();
            emrView = view;
        }

        private void btn_Cancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
        }

        private void btn_Ok_Click(object sender, EventArgs e)
        {
            if (!ckb_yawei.Checked && !ckb_yuejing.Checked && !cbk_fangjiao.Checked)
            {
                MessageBox.Show("请勾选一个公式", "命令提示");
                return;
            }
            if (ckb_yawei.Checked)
            {
                item = new EmrToothItem(emrView.ActiveSectionTopLevelData(),
                    "XX", "XX", "XX", "XX");
            }
            if (ckb_yuejing.Checked)
            {
                item = new EmrYueJingItem(emrView.ActiveSectionTopLevelData(),
                "12", "5-6", string.Format("{0:yyyy-MM-dd}", DateTime.Now), "28-30"); ;
            }
            if (cbk_fangjiao.Checked)
            {
                item = new EmrFangJiaoItem(emrView.ActiveSectionTopLevelData(), "", "", "", "");
            }
            this.DialogResult = DialogResult.OK;
        }

        private void ckb_CheckedChanged(object sender, EventArgs e)
        {
            var temp = (CheckBox)sender;
            if (temp.Checked)
            {
                foreach (Control item in this.Controls)
                {
                    if (item is CheckBox)
                    {
                        if (item != temp)
                        {
                            (item as CheckBox).Checked = false;
                        }
                    }
                }
            }
        }
    }
}
